package com.hm.scala.singleton

class Marker(val color: String) {

  println("Creating " + this)

  override def toString(): String = "maker color " + color;
}

object MakerFactory {

  private val makers = Map(
    "red" -> new Marker("red"),
    "bule" -> new Marker("bule"),
    "green" -> new Marker("green"))

  def getMaker(color: String) = if (makers.contains(color)) makers(color) else null
}

object TestMakerFactory {

  def main(args: Array[String]): Unit = {

    println(MakerFactory.getMaker("green"))

  }
}